﻿@model Apps.Models.PUB.PUB_MATERIEL_TYPEModel
@using Apps.Web.Core;
@using Apps.Common;
@using Apps.Models.PUB;
@using Apps.Web;
@using Apps.Locale;
@using Apps.Models.Sys;
@{
    ViewBag.Title = "创建";
    Layout = "~/Views/Shared/_Index_LayoutEdit.cshtml";
    List<permModel> perm = null;
}

<div class="mvctool bgb">
    @Html.ToolButton("btnSave", "fa fa-save", Resource.Save, ref perm, "Save", true)
    @Html.ToolButton("btnReturn", "fa fa-reply", Resource.Reply, false)
</div>
@using (Html.BeginForm())
{
    @Html.Hidden("MATERIEL_TYPE_ID", ResultHelper.NewId)
    <table class="formtable">
        <tbody>
            <tr>
                <th>
                    @Html.LabelFor(model => model.MATERIEL_TYPE_NAME, 0)：
                </th>
                <td>
                    @Html.EditorFor(model => model.MATERIEL_TYPE_NAME)
                </td>
            </tr>
            <tr>
                <th>
                    @Html.LabelFor(model => model.IS_COAL, 0)：
                </th>
                <td>
                    @Html.SwitchDropdown("IS_COAL", true, "是", "否")
                </td>
            </tr>
            <tr>
                <th>
                    @Html.LabelFor(model => model.TEMPLATE_ID, 0)：
                </th>
                <td>
                    @Html.EditorFor(model => model.TEMPLATE_ID)
                    @*@Html.DropDownListFor(model => model.TEMPLATE_ID, ViewBag.CTemplate as SelectList, "")*@
                </td>
            </tr>
            <tr>
                <th>
                    @Html.LabelFor(model => model.REMARKS, 0)：
                </th>
                <td>
                    @Html.TextAreaFor(model => model.REMARKS, new { @style = "height:50px" })
                </td>
            </tr>
        </tbody>
    </table>
    @Html.ValidationSummary()
}

<script type="text/javascript">
    $(function () {
        $.ajax({
            url: "@Url.Action("GetTempList")",
            type: 'post',
            dataType: 'json',
            success: function (result) {
                $('#TEMPLATE_ID').combobox({
                    data: result,
                    valueField: 'Value',
                    textField: 'Text',
                    onLoadSuccess: function () {
                        $("#TEMPLATE_ID").combobox("setValue", "");
                    }
                });
            }
        });
        $("#btnSave").click(function () {
            if ($("form").valid()) {
                $.ajax({
                    url: "@Url.Action("CreateParent")",
                    type: "Post",
                    data: $("form").serialize(),
                    dataType: "json",
                    success: function (data) {
                        if (data.type == 1) {
                            window.parent.frameReturnByMes(data.message);
                            window.parent.frameReturnByReload(true);
                            window.parent.frameReturnByClose()
                        }
                        else {
                            window.parent.frameReturnByMes(data.message);
                        }
                    }
                });
            }
            return false;
        });
        $("#btnReturn").click(function () {
            window.parent.frameReturnByClose();
        });
    });
</script>

